<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Gets the first key of an array</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.array-key-first" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">array_key_first</h1>
  <p class="verinfo">(PHP 7 &gt;= 7.3.0)</p><p class="refpurpose"><span class="refname">array_key_first</span> &mdash; <span class="dc-title">Gets the first key of an array</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.array-key-first-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>array_key_first</strong></span>
    ( <span class="methodparam"><span class="type">array</span> <code class="parameter">$array</code></span>
   ) : <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span></div>

  <p class="para rdfs-comment">
   Get the first key of the given <code class="parameter">array</code> without affecting
   the internal array pointer.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.array-key-first-parameters">
  <h3 class="title">参数</h3>
  <dl>

   
    <dt>
<code class="parameter">array</code></dt>

    <dd>

     <p class="para">
      An array.
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.array-key-first-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns the first key of <code class="parameter">array</code> if the array is not empty;
   <strong><code>NULL</code></strong> otherwise.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.array-key-first-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="function.array-fill.example.basic">
    <p><strong>Example #1 Basic <span class="function"><strong>array_key_first()</strong></span> Usage</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$array&nbsp;</span><span style="color: #007700">=&nbsp;[</span><span style="color: #DD0000">'a'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'b'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">2</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'c'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">3</span><span style="color: #007700">];<br /><br /></span><span style="color: #0000BB">$firstKey&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">array_key_first</span><span style="color: #007700">(</span><span style="color: #0000BB">$array</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$firstKey</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
string(1) &quot;a&quot;
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.array-key-first-seealso">
  <h3 class="title">参见</h3>
  <ul class="simplelist">
   <li class="member"><span class="function"><a href="array_key_last.html" class="function" rel="rdfs-seeAlso">array_key_last()</a> - Gets the last key of an array</span></li>
   <li class="member"><span class="function"><a href="reset.html" class="function" rel="rdfs-seeAlso">reset()</a> - 将数组的内部指针指向第一个单元</span></li>
  </ul>
 </div>


</div></div></div></body></html>